﻿//界面的显示
Console.Write("hello!");
Console.Write("点击空格来结束程序");
//清屏
Console.Clear();
//设置初始位置
int x = 10, y = 10;
Console.SetCursorPosition(x, y);
//使其进行移动
while (true)
{
    var input = Console.ReadKey().Key;


    Console.Clear();
    switch (input)
    {
        //shift left
        case ConsoleKey.A:

            {
                if (--x < 0)
                    x = 0;
                Console.SetCursorPosition(x, y);
                Console.WriteLine("hello");
                break;
            }
        //move down

        case ConsoleKey.S:
            {
                if (++y < 0)
                    y = 0;
                Console.SetCursorPosition(x, y);
                Console.WriteLine("hello");
                break;
            }
        //shift right

        case ConsoleKey.D:
            {
                if (++x < 0)
                    x = 0;
                Console.SetCursorPosition(x, y);
                Console.WriteLine("hello");
                break;
            }
        //move up

        case ConsoleKey.W:
            {
                if (--y < 0)
                    y = 0;
                Console.SetCursorPosition(x, y);
                Console.WriteLine("hello");
                break;
            }
        //end the program

        case ConsoleKey.Backspace:
            Console.WriteLine("结束程序");
            break;
        default:
            break;
    }
}
